MkConfigSetting
Node for describing a config setting.¶
Example: YAML format¶
Jinja
Python
**path**
-
Default:
'path.to.module'
Some markdown to describe the setting
Example: JSON format¶
Jinja
Python
**path**
-
Default:
'path.to.module'
Some markdown to describe the setting
<p><code>**path**</code>
: Default: <code>'path.to.module'</code></p>
<div class="language-text highlight"><pre><span></span><code>Some **markdown** to describe the setting
```` {.json }
{
"plugins": {
"mknodes": {
"path": "path.to.module"
}
}
}
````
</code></pre></div>
Example: TOML format¶
Jinja
Python
**path**
-
Default:
'path.to.module'
Some markdown to describe the setting
Bases: MkTemplate
__init__
¶
__init__(
title: str,
description: str,
*,
setting: dict[str, Any] | str | None = None,
default: str | int | None = None,
version_added: str | None = None,
optional: bool | None = None,
mode: MarkupTypeStr | None = None,
**kwargs: Any
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Setting title |
required |
description
|
str
|
Setting description |
required |
setting
|
dict[str, Any] | str | None
|
(Nested) json-like object representing the setting |
None
|
default
|
str | int | None
|
Default setting value |
None
|
version_added
|
str | None
|
Version added |
None
|
optional
|
bool | None
|
Whether setting is optional. (None hides the label) |
None
|
mode
|
MarkupTypeStr | None
|
Markup language of settings file |
None
|
kwargs
|
Any
|
Keyword arguments passed to parent |
{}
|
Name | Children | Inherits |
---|---|---|
MkTemplate mknodes.templatenodes.mktemplate Node representing a jinja template. |
graph TD
94721312017328["mkconfigsetting.MkConfigSetting"]
94721308869584["mktemplate.MkTemplate"]
94721311697232["mkcontainer.MkContainer"]
94721308848336["mknode.MkNode"]
94721311766592["node.Node"]
140564252373184["builtins.object"]
94721308869584 --> 94721312017328
94721311697232 --> 94721308869584
94721308848336 --> 94721311697232
94721311766592 --> 94721308848336
140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkconfigsetting/metadata.toml
[metadata]
name = "MkConfigSetting"
icon = "mdi:library"
virtual_children = true
[requirements.extension.def_list]
[examples.yaml]
title = "YAML format"
jinja = """
{{ "path" | MkConfigSetting(mode="yaml",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[examples.json]
title = "JSON format"
jinja = """
{{ "path" | MkConfigSetting(mode="json",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[examples.toml]
title = "TOML format"
jinja = """
{{ "path" | MkConfigSetting(mode="toml",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[output.markdown]
template = """
{{ node.title | md_style(bold=True, code=True) }}
: {% filter indent %}Default: `{{ node.default | repr }}`
{% if node.version_added %}
Version added: `{{ node.version_added }}`
{% endif %}
{% if node.optional is not none %}
Required: `{{ "yes" if node.required else "no" }}`
{% endif %}
{{ node.description }}
{% if node.setting is instance(dict) %}
{{ node.setting | serialize(node.mode) | MkCode(language=node.mode) }}
{% else %}
{{ node.setting | MkCode(language=node.mode) }}
{% endif %}
{% endfilter %}
"""